<template>
  <div class="page-container">

    <!--审核弹框-->
    <el-dialog title="管理员备注" width="50%" :visible.sync="dialogVisibleAdmin" :close-on-click-modal="false" @closed="handleClose">
      <el-form :model="adminDataForm" label-width="100%" :size="size"
               label-position="right" inline>
        <el-form-item>
          <div style="width:100%;">
            <el-input
              type="textarea"
              placeholder="请输入备注"
              v-model="adminDataForm.auditRemark">
              :rows="4"
            </el-input>
          </div>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer" style="text-align:center">
        <el-button :size="size" @click.native="submitFormAdminNotPass" type="primary">不通过</el-button>
        <el-button :size="size" type="primary" @click.native="submitFormAdmin">通过</el-button>
      </div>
    </el-dialog>


    <!--工具栏-->
        <div class="toolbar" style="float:left;padding-top:10px;padding-left:15px;width: 100%;">
          <el-form :inline="true" :model="filters" :size="size" ref="filters" class="border" style="margin-bottom: 15px;">
            <div style="width: 100%;">
              <el-form-item style="width:32%">
                <span style="color: #999;">活动名称</span>
                <span style="margin-left:10px;">{{filters.promName}}</span>
              </el-form-item>
              <el-form-item style="width:32%">
                <span style="color: #999;">活动ID</span>
                <span style="margin-left:10px;">{{filters.id}}</span>
              </el-form-item>
              <el-form-item style="width:32%">
                <span style="color: #999;">当前状态</span>
                <!--<span style="margin-left:10px;">活动名称</span>-->

                <span style="margin-left:10px;" v-if="filters.status =='1'">进行中</span>
                <span style="margin-left:10px;" v-if="filters.status =='2'">已过期</span>
                <span style="margin-left:10px;" v-if="filters.status =='3'">已关闭</span>
                <span style="margin-left:10px;" v-if="filters.status =='4'">未开始</span>
                <span style="margin-left:10px;" v-if="filters.status =='5'">待提交</span>
                <span style="margin-left:10px;" v-if="filters.status =='6'">待审核</span>
                <span style="margin-left:10px;" v-if="filters.status =='7'">审核未通过</span>

              </el-form-item>
            </div>
          </el-form>
           <el-form :inline="true" :model="filters" :size="size" ref="filters" style="text-align: center;">
             <span v-if="filters.status =='6'">
              <div style="margin-top:20px;" v-if="shenhe == 0">
              <el-button type="primary" @click="shenheHuodong(1)">审核</el-button>
                </div>
             </span>
             <span v-if="filters.status =='5'">
               <div style="margin-top:20px;" v-if="shenhe == 0">
                <el-button type="primary" plain :size="size" @click="shenheHuodong(0)">提交审核</el-button>
              </div>
              <div style="margin-top:20px;" v-if="shenhe == 1">
                  <el-button type="primary" plain :size="size" @click="shenheHuodong(1)">审核</el-button>
              </div>
             </span>
           </el-form>
        </div>
          <div class="tab-container">
            <el-alert :closable="false" style="background-color: #ffffff;color: #ffffff;" title="" type="success" />
            <el-tabs type="border-card">
              <el-tab-pane label="促销规则">
                <div>
                  <form class="form-horizontal ">
                    <div class="pdL10 border-left font-bold mgB15 ng-binding">基本信息</div>
                    <div class="form-group">
                      <!--活动名称-->
                      <label class="col-sm-2 control-label ng-binding" ng-show="promotionDetailContent.promotionMethod != 17">活动名称</label>
                      <!-- <label class="col-sm-2 control-label ng-binding ng-hide" ng-show="promotionDetailContent.promotionType == 13 &amp;&amp; promotionDetailContent.promotionMethod == 17">定金支付时间</label> -->
                      <div class="col-sm-10 pdt3px themeTextColor ng-binding">
                        {{activityData.promName}}
                      </div>
                    </div>
                    <div class="line line-dashed b-b line-lg  ng-scope"></div>
                    <div class="form-group">
                      <!--活动时间-->
                      <label class="col-sm-2 control-label ng-binding" >活动时间</label>
                      <!-- <label class="col-sm-2 control-label ng-binding ng-hide" v-show="promotionDetail.promotionType == 13 || promotionDetail.promotionType == 17">定金支付时间</label> -->
                      <div class="col-sm-10 pdt3px themeTextColor ng-binding">
                        {{activityData.startTime}} 至 {{activityData.endTime}}
                      </div>
                    </div>
                    <div class="line line-dashed b-b line-lg  ng-scope"></div>
                    <div class="pdL10 border-left font-bold mgB15 ng-binding">活动规则</div>
                    <div class="form-group ng-scope">
                      <!--活动类型(促销类型)-->
                      <label class="col-sm-2 control-label ng-binding">活动类型</label>
                      <div class="col-sm-10 pdt3px themeTextColor ng-binding">
                        {{getFrontPromType(activityData.frontPromType)}}
                      </div>
                    </div>
                    <div class="line line-dashed b-b line-lg  ng-scope"></div>
                    <div class="form-group" v-show="false">
                      <!--参与方式-->
                      <label class="col-sm-2 control-label ng-binding">活动形式</label>
                      <div class="col-sm-10 pdt3px themeTextColor ng-binding">
                        自建
                      </div>
                    </div>
                    <div class="line line-dashed b-b line-lg  ng-scope"></div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label ng-binding">活动规则说明</label>
                      <div class="col-sm-5 pdt3px ng-binding">
                        {{activityData.description}}
                      </div>
                    </div>
                    <div class="line line-dashed b-b line-lg  ng-scope"></div>
                    <div class="pdL10 border-left font-bold mgB15 ng-binding ng-scope">交易规则</div>
                    <div class="form-group">
                      <!--是否支持折上折-->
                      <label class="col-sm-2 control-label ng-binding">是否支持折上折</label>
                      <div class="col-sm-10 pdt3px themeTextColor">
                        <span  v-if="activityData.foldingFlag==1" class="ng-binding ng-scope">是</span>
                        <span  v-else class="ng-binding ng-scope">否</span>
                      </div>
                    </div>
                    <div class="line line-dashed b-b line-lg  ng-scope"></div>
                    <div class="form-group" v-show="false">
                      <!--是否排斥优惠券-->
                      <label class="col-sm-2 control-label ng-binding">是否排斥优惠券</label>
                      <!-- <label class="col-sm-2 control-label ng-binding ng-hide">是否排斥优惠券（尾款支付）</label> -->
                      <div class="col-sm-10 pdt3px themeTextColor ng-binding">
                        否
                      </div>
                    </div>
                    <div class="line line-dashed b-b line-lg  ng-scope"></div>
                    <div class="form-group ng-scope" v-show="false">
                      <!--是否包邮-->
                      <label class="col-sm-2 control-label ng-binding" >是否包邮</label>
                      <!-- <label class="col-sm-2 control-label ng-binding ng-hide" ng-show="promotionDetailContent.promotionType==9">包邮方式</label> -->
                      <div class="col-sm-10 pdt3px themeTextColor ng-binding">
                        否
                      </div>
                    </div>
                    <div class="line line-dashed b-b line-lg  ng-scope"></div>
                    <div class="form-group ng-scope" ng-if="promotionDetailContent.promotionType == 1 || promotionDetailContent.promotionType == 14">
                      <label class="col-sm-2 control-label ng-binding">超限规则</label>
                      <div class="col-sm-10 pdt3px themeTextColor ng-binding">
                        <span  v-if="activityData.foldingFlag==1" class="ng-binding ng-scope">按原价购买</span>
                        <span  v-else class="ng-binding ng-scope">不可购买</span>
                      </div>
                    </div>
                    <div class="line line-dashed b-b line-lg  ng-scope"></div>
                    <div v-show="false" class="">
                      <div class="col-sm-2 control-label">
                        <label class="ng-binding"> 供应商分摊比例：</label>
                      </div>
                      <div class="col-sm-10 control-label">
                        <table border="1">
                          <thead>
                          <tr>
                            <th class="minw110 textCenter">供应商ID</th>
                            <th class="minw110 textCenter">供应商名称</th>
                            <th class="minw110 textCenter">分摊比例</th>
                          </tr>
                          </thead>
                          <tbody>
                          <!-- ngRepeat: e in promotionDetailContent.selectedSupplierList -->
                          </tbody>
                        </table>
                      </div>
                    </div>
                    <div class="line line-dashed b-b line-lg  ng-scope"></div>
                    <div class="pdL10 border-left font-bold mgB15 ng-binding">
                      参与条件
                    </div>
                    <div class="line line-dashed b-b line-lg  ng-scope"></div>
                    <div ng-controller="activitiObjDetailCtrl" class="ng-scope">
                      <!--活动渠道-->
                      <div class="line line-dashed b-b line-lg" ng-show="promotionDetailContent.channelCodes.length > 0"></div>
                      <div class="form-group ng-scope" ng-if="promotionDetailContent.channelCodes.length > 0">
                        <label class="col-sm-2 control-label ng-binding">活动渠道</label>

                        <div class="col-sm-10 pdt3px">
                          <span v-for="(item) in (activityData.channelCodes + '').split('|')" :key="item" class="ng-binding ng-scope">{{getChannelCodes(item)}} &nbsp;</span>
                          <!-- <span ng-repeat="channel in promotionDetailContent.channelCodes" class="ng-binding ng-scope">BBC &nbsp;</span> -->
                        </div>
                      </div>

                      <div class="line line-dashed b-b line-lg" ng-show="canShowActivityPlatformLimitShow()"></div>
                      <div class="form-group ng-scope" ng-if="canShowActivityPlatformLimitShow()">
                        <label class="col-sm-2 control-label ng-binding">活动平台</label>

                        <div class="col-sm-10 pdt3px">
                          <span v-for="(item) in (activityData.proPlatform + '').split('|')" :key="item" class="ng-binding ng-scope">{{getProPlatform(item)}} &nbsp;</span>
                          <!-- <span ng-repeat="applicablePlatform in promotionDetailContent.applicablePlatformList" class="ng-binding ng-scope">APP端 &nbsp;</span>
                          <span ng-repeat="applicablePlatform in promotionDetailContent.applicablePlatformList" class="ng-binding ng-scope">PC端 &nbsp;</span>
                          <span ng-repeat="applicablePlatform in promotionDetailContent.applicablePlatformList" class="ng-binding ng-scope">微信 &nbsp;</span> -->
                        </div>
                      </div>

                      <div class="line line-dashed b-b line-lg  "></div>
                      <div class="form-group">
                        <label class="col-sm-2 control-label ng-binding">新老用户</label>
                        <div class="col-sm-10 pdt3px">
                          <span v-for="(item) in (activityData.proUserType + '').split('|')" :key="item" class="ng-binding ng-scope">{{getProUserType(item)}} &nbsp;</span>
                          <!-- <span ng-repeat="userScope in promotionDetailContent.userScopeList" class="ng-binding ng-scope">新用户 &nbsp;</span> -->
                        </div>
                      </div>
                      <div class="line line-dashed b-b line-lg  "></div>
                      <div class="form-group">
                        <label class="col-sm-2 control-label ng-binding">会员类型</label>
                        <div class="col-sm-10 pdt3px">
                          <span v-for="(item) in (activityData.proMemberType + '').split('|')" :key="item" class="ng-binding ng-scope">{{getProMemberType(item)}} &nbsp;</span>
                          <!-- <span ng-repeat="type in promotionDetailContent.memberTypeList" class="ng-binding ng-scope">普通会员 &nbsp;</span> -->
                        </div>
                      </div>
                      <!-- 会员等级(修改) -->
                      <div class="line line-dashed b-b line-lg  "></div>
                      <div class="form-group">
                        <div ng-repeat="e in memberLevelArray" class="ng-scope">
                          <label class="col-sm-2 control-label ng-binding ng-scope" ng-if="$index==0">会员等级:</label>
                          <div class="col-sm-10 pdt3px">
                            <span v-for="(item) in (activityData.proMemberLevel + '').split('|')" :key="item" class="ng-binding ng-scope">{{getProMemberLevel(item)}} &nbsp;</span>
                            <!-- <span ng-repeat="applicablePlatform in promotionDetailContent.applicablePlatformList" class="ng-binding ng-scope">普通会员 &nbsp;</span> -->
                            <!-- <span ng-repeat="applicablePlatform in promotionDetailContent.applicablePlatformList" class="ng-binding ng-scope">注册用户 &nbsp;</span> -->
                            <!-- <span ng-repeat="applicablePlatform in promotionDetailContent.applicablePlatformList" class="ng-binding ng-scope">VIP会员金卡 &nbsp;</span> -->
                            <!-- <span ng-repeat="applicablePlatform in promotionDetailContent.applicablePlatformList" class="ng-binding ng-scope">金卡 &nbsp;</span> -->
                          </div>
                        </div>
                      </div>
                      <div class="line line-dashed b-b line-lg  "></div>
                      <div class="form-group ng-scope" ng-if="promotionDetailContent.promotionType != 12">
                        <!--备注-->
                        <label class="col-sm-2 control-label ng-binding">备注</label>
                        <div class="col-sm-10 pdt3px themeTextColor">
                          <quill-editor
                            v-model="activityData.remark"
                            ref="myQuillEditor"
                            style="height: 300px;"

                          >{{activityData.remark}}</quill-editor>
                        </div>
                      </div>
                    </div>
                  </form>
                </div>
              </el-tab-pane>
              <el-tab-pane label="参与商家/店铺">
                <el-tabs type="border-card">

                  <!--<el-tab-pane label="商家">-->
                    <!--<el-table :data="businessList" border style="width: 100%">-->
                      <!--<el-table-column prop="id" label="商品编码"></el-table-column>-->
                      <!--<el-table-column prop="name" label="商家名称"></el-table-column>-->
                      <!--<el-table-column prop="type" label="组织分类"></el-table-column>-->
                    <!--</el-table>-->
                  <!--</el-tab-pane>-->

                  <!--<el-tab-pane label="店铺">-->
                    <!--<el-table :data="shopList" border style="width: 100%">-->
                      <!--<el-table-column prop="id" label="店铺编码"></el-table-column>-->
                      <!--<el-table-column prop="name" label="店铺名称"></el-table-column>-->
                      <!--<el-table-column prop="type" label="店铺类型"></el-table-column>-->
                    <!--</el-table>-->
                  <!--</el-tab-pane>-->

                  <el-tab-pane label="商家">
                    <!--<div style="float: left;margin-bottom: 10px;"  >-->
                      <!--<el-button type="primary" size="mini" @click="querySupplierListForAdd()">添加商家</el-button>-->
                      <!--<el-button type="danger" size="mini" @click="delAllSelectedSuppliermerchantTableData2()">批量删除</el-button>-->
                    <!--</div>-->
                    <el-table :data="merchantTableData2" border style="width: 100%"
                    >
                      <!--<el-table-column type="selection"></el-table-column>-->
                      <el-table-column prop="id" label="商品编号">
                        <template slot-scope="scope">
                          <span>{{ scope.row.orgNumber}}</span>
                        </template>
                      </el-table-column>
                      <el-table-column prop="name" label="商家名称">
                        <template slot-scope="scope">
                          <span>{{ scope.row.name}}</span>
                        </template>
                      </el-table-column>
                      <el-table-column prop="type" label="组织分类">
                        <template slot-scope="scope">
                          <!--<span>{{ scope.row.merchantType}}</span>-->
                          <span v-if="scope.row.merchantType =='1'">自营商家</span>
                          <span v-if="scope.row.merchantType =='2'">第三方商户</span>
                        </template>
                      </el-table-column>
                      <!--<el-table-column label="操作"   >-->
                        <!--<template slot-scope="scope">-->
                          <!--<el-button  type="text" class="textButton" @click="merchantTableData2delete(scope.row.id)">删除</el-button>-->
                        <!--</template>-->
                      <!--</el-table-column>-->
                    </el-table>
                    <!--分页栏-->
                    <div class="toolbar" style="padding:10px;">
                      <el-pagination
                        layout="total, sizes, prev, pager, next, jumper"
                        @current-change="mainMerchantRefreshPageRequest"
                        :current-page="mainMerchantForm.pageNo"
                        :page-size="mainMerchantForm.pageSize"
                        :total="mainMerchantTableDataTatol"
                        style="float:right;"
                        :page-sizes="[10, 20, 30, 40]"
                        @size-change="mainMerchantHandleSizeChange"
                      ></el-pagination>
                    </div>
                  </el-tab-pane>


                  <el-tab-pane label="店铺">
                    <!--<div style="float: left;margin-bottom: 10px;"  >-->
                      <!--<el-button type="primary" size="mini" @click="querySupplierListForAdd2()">添加店铺</el-button>-->
                      <!--<el-button type="danger" size="mini" @click="delAllSelectedSupplierstoreTableData()">批量删除</el-button>-->
                    <!--</div>-->
                    <el-table :data="storeTableData" border style="width: 100%">
                      <!--<el-table-column type="selection"></el-table-column>-->
                      <el-table-column label="店铺编号">
                        <template slot-scope="scope">
                          <span>{{ scope.row.storecode}}</span>
                        </template>
                      </el-table-column>
                      <el-table-column  label="店铺名称">
                        <template slot-scope="scope">
                          <span>{{ scope.row.storename}}</span>
                        </template>
                      </el-table-column>
                      <el-table-column  label="店铺类型">
                        <template slot-scope="scope">
                          <span v-if="scope.row.storeType =='1'">线上店铺</span>
                        </template>
                      </el-table-column>
                      <!--<el-table-column  label="操作"   >-->
                        <!--<template slot-scope="scope">-->
                          <!--<el-button  type="text" class="textButton"  @click="storeDelete(scope.row.id)">删除</el-button>-->
                        <!--</template>-->
                      <!--</el-table-column>-->
                    </el-table>
                    <!--分页栏-->
                    <div class="toolbar" style="padding:10px;">
                      <el-pagination
                        layout="total, sizes, prev, pager, next, jumper"
                        @current-change="mainSroreMerchantRefreshPageRequest"
                        :current-page="mainStoreMerchantForm.pageNo"
                        :page-size="mainStoreMerchantForm.pageSize"
                        :total="storeTableDataTatol"
                        style="float:right;"
                        :page-sizes="[10, 20, 30, 40]"
                        @size-change="mainSroreMerchantHandleSizeChange"
                      ></el-pagination>
                    </div>
                  </el-tab-pane>



                </el-tabs>
              </el-tab-pane>
              <el-tab-pane label="参与商品">
                <div style=" height: 40px;"><el-button size="mini" style="float: left;" type="primary" @click="revokeProduct()">撤出商品</el-button></div>
                <div>
                <el-tabs type="border-card">
                  <el-tab-pane label="生效商品">
                      <el-table :data="tableDataData" border style="width: 100%" @selection-change="handleSelectionChange">
                        <!--<el-table-column type="selection" width="55"></el-table-column>-->
                        <el-table-column prop="mpCode" label="商品编码" width="180"></el-table-column>
                        <el-table-column prop="mpName" label="商品名称" width="180"></el-table-column>
                        <el-table-column prop="mpParentId" label="父商品ID"></el-table-column>
                        <el-table-column prop="merchantId" label="商家ID"></el-table-column>
                        <el-table-column prop="merchantName" label="商家名称"></el-table-column>
                        <el-table-column prop="storeName" label="店铺名称"></el-table-column>
                        <el-table-column prop="salePriceWithTax" label="统一零售价（元）"></el-table-column>
                        <!--<el-table-column prop="markdown" label="直降（元）"></el-table-column>-->
                        <!--<el-table-column prop="shopLimit1" label="商家单渠道限购"></el-table-column>-->
                        <!--<el-table-column prop="shopLimit2" label="店铺单渠道限购"></el-table-column>-->
                        <!--<el-table-column prop="shopLimit3" label="个人单渠道限购"></el-table-column>-->
                        <!--<el-table-column prop="address" label="订单限购"></el-table-column>-->
                      </el-table>
                  </el-tab-pane>
                  <el-tab-pane label="互斥商品">
                      <el-table border style="width: 100%">
                        <el-table-column prop="id" label="商品编码" width="180"></el-table-column>
                        <el-table-column prop="productName" label="商品名称" width="180"></el-table-column>
                        <el-table-column prop="address" label="商品条码"></el-table-column>
                        <el-table-column prop="unit" label="计量单位"></el-table-column>
                        <el-table-column prop="shopName" label="商家名称"></el-table-column>
                        <el-table-column prop="price" label="互斥记录时间"></el-table-column>
                        <el-table-column prop="markdown" label="操作"></el-table-column>
                      </el-table>
                  </el-tab-pane>
                </el-tabs>
                </div>
              </el-tab-pane>
            </el-tabs>
          </div>
  </div>
</template>

<script>
import KtButton from "@/views/Core/KtButton";
import { format } from "@/utils/datetime";
import TableColumnFilterDialog from "@/views/Core/TableColumnFilterDialog";
import { darkmagenta } from 'color-name';
import tabPane from './components/TabPaneCreateGroupon'
import qs from 'qs';
import { promTypeConverter, frontPromTypeConverter,channelCodeConverter,proPlatformConverter, proUserTypeConverter,proMemberTypeConverter ,proMemberLevelConverter} from "@/market/dict/marketDict";

export default {
  name: 'Tab',
  components: {
    tabPane ,
    KtButton,
    TableColumnFilterDialog
  },
  data() {
    return {
      adminDataForm:{
        auditRemark:""
      },
      dialogVisibleAdmin: false,
      shenhe:0,
      size: "small",
      multipleSelection: [],
      businessList: [{"id": "001", "name": "张小二服饰", "type": "自营商家"}],
      shopList: [{"id": "161616", "name": "张小二bbc店铺", "type": "直营"}],
      tableData: [{
        "id": 1912250010887324,
        "productName": "新供应商001",
        "unit": '件',
        "shopName": '张小二服饰',
        "price": 1.2,
        "markdown": 1,
        "shopLimit1": 100,
        "shopLimit2": 100,
        "shopLimit3": 100,
      }],
      tableDataData:[],
      activityData: {
        id: "",
        activityTitle: "",
        groupMembers: "",
        startTime: "",
        endTime: "",
        createUsername: "",
        status: "",
        channelCode: "",
        createDate: ""
      },
      filters: {
        "id":"",
        "status":"",
        // "promType":1,//单一促销
        "promName": "",
        "frontPromType": 2,
        "foldingFlag": 1,
        "overLimitRule": 2,
        "channelCodes": "110001",
        "customerLimit": "0",
        "offeredCustomerLimit": "0",
        "remark": "",
        "proPlatform": [1],
        "proUserType": [1],
        "proMemberType": [1],
        "proMemberLevel": [2],
        "createMerchantId":11,
        "createMerchantName":"wys",
        "contentType":1,
        "creator":1,
        "creatorName":"admin",
        "updator":1,
        "updatorName":"admin",
        "groupMembers":"",
        "groupType":"0",
        "groupTimeType":"0",
        "groupTimeLimit":"",
        "autoCompleteTime":"",
        "individualJoinType":"0",
        "individualJoinTime":"",
        "mailType":"0",
        "startTime": "",
        "endTime": "",
        "fileUrl":"https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=d&word=%E6%8B%BC%E5%9B%A2%E6%B4%BB%E5%8A%A8%E5%9B%BE%E7%89%87&step_word=&hs=2&pn=0&spn=0&di=181610&pi=0&rn=1&tn=baiduimagedetail&is=0%2C0&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=1564405255%2C2033570230&os=4151028045%2C4024279481&simid=4269565477%2C911268859&adpicid=0&lpn=0&ln=1387&fr=&fmq=1579251110715_R&fm=&ic=undefined&s=undefined&hd=undefined&latest=undefined&copyright=undefined&se=&sme=&tab=0&width=undefined&height=undefined&face=undefined&ist=&jit=&cg=&bdtype=0&oriquery=&objurl=http%3A%2F%2Fimage.xghylt.com%2Fforum%2F201712%2F21%2F110528yqdenajc52jhjj7h.jpg.thumb.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3Fks52_z%26e3Bftgw_z%26e3Bv54_z%26e3BvgAzdH3FfAzdH3Fks52_80jc8c91da8adxwf6_z%26e3Bip4s&gsm=&rpstart=0&rpnum=0&islist=&querylist=&force=undefined"
      },


      //-----------setp2###start

      //第一步添加成功赋值
      //外部赋值-----------------start
      promotionId:"1",
      auth:0,
      //外部赋值-----------------start

      promotion:{
        //促销id
        id:"",
        promotionId:"",
        merchantType:"1",
      },
      pomotionListObject:{pomotionList:[]},
      mainMerchantForm:{
        promotionId: "",
        merchantType:"1",
        pageNo:1,
        pageSize:10,
        orderBys:{
          "f":"create_time",
          "s":"desc"
        }
      },
      mainMerchantTableDataTatol: 0,
      merchantForm: {
        start:1,
        limit:10,
      },
      merchantFormStore: {
        start:1,
        limit:10,
      },
      merchantTableDataTatol: 0,
      merchantTableDataTatolStore: 0,
      merchantTableData: [
      ],
      //选择的商家列表
      merchantTableData2: [
      ],
      storeForm:{
        start:1,
        limit:10,
        ids:"",
        storename:"",
        storecode:"",
        orgNumber:"",
        name:"",
      },

      mainStoreMerchantForm:{
        promotionId: "",
        merchantType:"2",
        pageNo:1,
        pageSize:10,
        orderBys:{
          "f":"create_time",
          "s":"desc"
        }
      },
      storeTableDataTatol: 0,
      storeTableData:[
      ],
      //选择店铺
      storeTableData2Tatol: 0,
      storeTableData2: [],
      //选择店铺
      addSelectionStoreTableData2: [],
      merchantTableData2Selection:[],
      merchantTableData2SelectionIndex:0,
      storeTableDataSelection:[],
      storeTableDataSelectionIndex:0,
      editDialogVisible:false,
      editDialogVisible2:false,
      //-----------setp2###end
      activityData: {

      },

    };
  },
  methods: {
    submitFormAdminNotPass(){
      this.dialogVisibleAdmin = false;

      let callback = res => {
        console.log(res);
      };
      this.adminDataForm.id = this.promotionId;
      this.adminDataForm.status = 7;
      this.utils.request.patchGrouponUpdate(this.adminDataForm, callback);
      this.shenhe = 0;
    },
    submitFormAdmin(){
      this.dialogVisibleAdmin = false;

      let callback = res => {
        console.log(res);
      };
      this.adminDataForm.id = this.promotionId;
      this.adminDataForm.status = 4;
      this.utils.request.patchGrouponUpdate(this.adminDataForm, callback);
    },

    shenheHuodong(flag){
      if(flag == 0){

        this.$confirm("是否确认提交审核？", "提示", {
          type: "warning"
        })
          .then(() => {
            this.shenhe = 1;

            let callback = res => {
              console.log(res);
            };
            let param ={};
            param.promotionId    =this.promotionId;
            param.status         =6;

            this.utils.request.updateGroupPromotionStatus(param,callback);

          })
          .catch(() => {
          });
      }else{
        this.shenhe = 2;
        this.dialogVisibleAdmin = true;
      }
    },

    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    revokeProduct() {
      if (this.multipleSelection.length > 0) {
        this.tableData = [];
        this.$message({ message: "操作成功", type: "success" });
      } else {
        this.$message({message: "操作失败, 请选择要撤出的商品",type: "error"});
      }
    },
    createPage(){
      this.$router.push("/CreatePromotion");
    },


    //------setp2###start

    delAllSelectedSupplierstoreTableData(){
      let ids = this.storeTableDataSelection.map(item => item.id).toString();
      let idArray = (ids + "").split(",");
      this.delAllSelectedSupplierstoreTableDataQueryList(idArray);
    },
    delAllSelectedSupplierstoreTableDataQueryList(idArray){
      let that = this;
      this.promotion.merchantType = "2";
      this.promotion.id = idArray[this.storeTableDataSelectionIndex];
      this.utils.request.promotionMerchantDeleteById2(this.promotion, function(){
        that.storeTableDataSelectionIndex++;
        if(that.storeTableDataSelectionIndex<=idArray.length){
          that.delAllSelectedSupplierstoreTableDataQueryList(idArray)
        }else{
          //执行成功
          that.storeTableDataSelectionIndex = 0;
          that.$message({message: "删除成功", type: "success"});
          that.mainStoreTableDataFormFind();
        }
      });
    },
    //批量删除商家
    delAllSelectedSuppliermerchantTableData2() {
      // this.merchantTableData2Selection;
      let ids = this.merchantTableData2Selection.map(item => item.id).toString();
      let idArray = (ids + "").split(",");
      this.delAllSelectedSupplierQueryList(idArray);
    },
    delAllSelectedSupplierQueryList(idArray){
      let that = this;
      this.promotion.merchantType = "1";
      this.promotion.id = idArray[this.merchantTableData2SelectionIndex];
      this.utils.request.promotionMerchantDeleteById2(this.promotion, function(){
        that.merchantTableData2SelectionIndex++;
        if(that.merchantTableData2SelectionIndex<=idArray.length){
          that.delAllSelectedSupplierQueryList(idArray)
        }else{
          //执行成功
          that.merchantTableData2SelectionIndex = 0;
          that.$message({message: "删除成功", type: "success"});
          that.mainMerchantFormFind();
        }
      });
    },
    //添加商家
    querySupplierListForAdd() {
      this.editDialogVisible = true;
      this.promotion.merchantType=1;
    },
    //添加店铺
    querySupplierListForAdd2() {
      this.editDialogVisible2 = true;
      this.promotion.merchantType=2;
    },

    //查询店铺
    storeFormFind(){
      //商家 取出商家id-->merchantId
      // this.merchantTableData2;


      let ids = this.merchantTableData2.map(item => item.merchantId).toString();

      console.log("----ids");
      console.log(this.merchantTableData2);
      console.log(ids);
      console.log("----ids---2");

      let params = [];
      console.log("----idArray---");
      let idArray = (ids + "").split(",");
      console.log(idArray);
      console.log("----idArray---2");

      for (var i = 0; i < idArray.length; i++) {
        params.push({id: idArray[i]});
      }

      console.log("----params");
      console.log(params);
      console.log("----params--2");



      console.log(this.merchantTableData.length);
      console.log("----");
      console.log(this.merchantTableData);

      // mergeTo = mergeTo.concat(mergeFrom);

      if(this.merchantTableData2.length==0) {
        this.$message({message: "请先选择商家", type: "success"});
      }

      // this.merchantTableDataTatol;
      this.storeTableData2.splice(0, this.storeTableData2.length);
      var  this__= this;
      this.storeForm.ids = ids;
      this.utils.request.queryByIds(this.storeForm, function (res) {
        console.log(res)
        if (res.code == "0000") {
          // this__.storeTableData2= this__.storeTableData2.concat(res.data);

          this__.storeTableData2= res.data;
          this__.merchantTableDataTatolStore = res.totle;
        }
      });


    },
    getProPlatform(code){
      return proPlatformConverter(code);
    },
    getProUserType(code){
      return proUserTypeConverter(code);
    },
    getChannelCodes(code){
      return channelCodeConverter(code);
    },
    getFrontPromType(code){
      return frontPromTypeConverter(code)
    },
    getProMemberType(code){
      return proMemberTypeConverter(code)
    },
    getProMemberLevel(code){
      return proMemberLevelConverter(code)
    },
    storeTableDataselectionChange(val){
      this.storeTableDataSelection=val;
    },
    merchantTableData2selectionChange(val){
      this.merchantTableData2Selection=val;
    },
    //选择店铺
    storeTableData2AddSelectionChange(val){
      this.addSelectionStoreTableData2=val;
    },
    //确定 选择店铺
    storeTableData2Click(){
      console.log(this.addSelectionStoreTableData2);
      // 调添加店铺 关系接口
      this.merchantTableDataSubmit2();
    },
    merchantTableDataSubmit2(){
      // this.merchantTableData2 = this.addSelection;

      let callback = res => {
        console.log(res);
        if (res.code == "0000") {
          this.storeSaveBatch();
        }
      };

      //调接口
      //删除这个活动老的数据
      //批量添加新的数据
      this.promotion.id=null;
      this.promotion.promotionId=this.promotionId;
      this.promotion.merchantType="2";
      this.utils.request.promotionMerchantDeleteByPromotionId2(this.promotion, callback);
    },

    //批量添加店铺
    storeSaveBatch(){
      console.log("storeSaveBatch");
      console.log(this.addSelectionStoreTableData2);
      console.log("storeSaveBatch2");
      this.pomotionListObject.pomotionList.splice(0,this.pomotionListObject.pomotionList.length);
      console.log("storeSaveBatch pomotionList");
      console.log(this.pomotionListObject.pomotionList);
      console.log("storeSaveBatch pomotionList2");

      for (var i = 0; i < this.addSelectionStoreTableData2.length; i++) {
        var temp = {};

        temp.promotionId         = this.promotionId;
        temp.storeId           =  this.addSelectionStoreTableData2[i].id;
        temp.merchantType        = "2";
        temp.storename        = this.addSelectionStoreTableData2[i].storename;
        temp.storecode =this.addSelectionStoreTableData2[i].storecode;
        temp.storeType           =this.addSelectionStoreTableData2[i].storeType;

        this.pomotionListObject.pomotionList.push(temp);
      }
      console.log("storeSaveBatch promotionMerchantSaveBatch2 push ok");
      console.log(this.pomotionListObject.pomotionList);
      console.log("storeSaveBatch promotionMerchantSaveBatch2 push ok2");

      let callback = res => {
        console.log(res);
        if (res.code == "0000") {
          this.mainStoreTableDataFormFind();
        }
      };

      this.utils.request.promotionMerchantSaveBatch2(this.pomotionListObject, callback );

    },
    //查询绑定关系的店铺
    mainStoreTableDataFormFind(){
      // this.storeTableData
      this.mainMerchantForm.merchantType="2";
      this.mainMerchantForm.promotionId=this.promotionId;
      var  this__= this;
      this.utils.request.promotionMerchantList2(this.mainMerchantForm, function (res) {
        console.log(res);
        if (res.code == "0000") {
          var ret = [];
          for (var i = 0; i < res.data.list.length; i++) {
            var temp = {};
            temp.promotionId         = res.data.list[i].promotionId;
            temp.id        = res.data.list[i].id;
            temp.storeId   =  res.data.list[i].storeId;
            temp.storename = res.data.list[i].storename;
            temp.storecode =  res.data.list[i].storecode;
            temp.storeType = res.data.list[i].storeType;

            ret.push(temp);
          }
          //店铺调试
          this__.storeTableData = res.data.list;
          this__.storeTableDataTatol = res.data.totalCount;
        }
      });
    },


    // 换页刷新
    mainSroreMerchantRefreshPageRequest: function (pageNum) {
      this.mainStoreMerchantForm.pageNo = pageNum;
      this.mainStoreTableDataFormFind();
    },
    // 换页刷新
    mainSroreMerchantHandleSizeChange: function (pageSize) {
      this.mainStoreMerchantForm.pageNo = 1;
      this.mainStoreMerchantForm.pageSize = pageSize;
      this.mainStoreTableDataFormFind();
    },


    // 换页刷新
    refreshPageRequestStore: function (pageNum) {
      this.storeForm.start = pageNum;
      // this.merchantFormFind();
      this.storeFormFind();
    },
    // 换页刷新
    handleSizeChangeStore: function (pageSize) {
      // this.merchantForm;
      this.storeForm.limit = pageSize;
      this.storeForm.start = 1;
      this.storeFormFind();
    },


    // 换页刷新
    refreshPageRequest: function (pageNum) {
      this.merchantForm.start = pageNum;
      this.merchantFormFind();
    },
    // 换页刷新
    handleSizeChange: function (pageSize) {
      this.merchantForm.limit = pageSize;
      this.merchantForm.start = 1;
      this.merchantFormFind();
    },

    // 换页刷新
    mainMerchantRefreshPageRequest: function (pageNum) {
      this.mainMerchantForm.pageNo = pageNum;
      this.mainMerchantFormFind();
    },
    // 换页刷新
    mainMerchantHandleSizeChange: function (pageSize) {
      this.mainMerchantForm.pageNo = 1;
      this.mainMerchantForm.pageSize = pageSize;
      this.mainMerchantFormFind();
    },
    //查询绑定关系的商家
    mainMerchantFormFind(){
      this.mainMerchantForm.merchantType="1";
      var  this__= this;
      this.mainMerchantForm.promotionId=this.promotionId;
      this.utils.request.promotionMerchantList2(this.mainMerchantForm, function (res) {

        console.log(res);
        if (res.code == "0000") {
          var ret = [];
          for (var i = 0; i < res.data.list.length; i++) {
            var temp = {};
            temp.id = res.data.list[i].id;
            temp.name = res.data.list[i].merchantName;
            temp.orgNumber =  res.data.list[i].orgNumber;
            temp.merchantType = res.data.list[i].merchantTypeManager;
            temp.merchantId=res.data.list[i].merchantId;

            ret.push(temp);
          }

          this__.merchantTableData2 = ret;
          this__.mainMerchantTableDataTatol = res.data.totalCount;
        }
      });
    },
    // 删除店铺
    storeDelete(id){
      console.log(id);
      console.log("删除店铺");

      let callback = res => {
        console.log(res);
        this.mainStoreTableDataFormFind();

        if (res.code == "0000" && res.data=="1") {
          //删除成功再调分页
          this.$message({message: "删除成功", type: "success"});

        }else{
          this.$message({message: "操作失败, " + res.msg, type: "error"});
        }
      };

      this.promotion.id = id;
      this.utils.request.promotionMerchantDeleteById2(this.promotion,callback);
    },

    //删除商家
    merchantTableData2delete(id){
      console.log(id);
      console.log("删除商家");

      let callback = res => {
        console.log(res);
        this.mainMerchantFormFind();
        if (res.code == "0000" && res.data=="1") {
          //删除成功再调分页
          this.$message({message: "删除成功", type: "success"});

        }else{
          this.$message({message: "操作失败, " + res.msg, type: "error"});
        }
      };

      this.promotion.id = id;
      this.utils.request.promotionMerchantDeleteById2(this.promotion,callback);
    },
    //选择商家
    addSelectionChange(val) {
      this.addSelection = val;
      console.log(this.addSelection);
    },
    //提交 选择商家
    merchantTableDataSubmit(){
      // this.merchantTableData2 = this.addSelection;

      let callback = res => {
        console.log(res);
        if (res.code == "0000") {
          this.promotionMerchantSaveBatch2();
        }
      };

      //调接口
      //删除这个活动老的数据
      //批量添加新的数据
      this.promotion.id=null;
      this.promotion.promotionId=this.promotionId;
      this.promotion.merchantType="1";
      this.utils.request.promotionMerchantDeleteByPromotionId2(this.promotion, callback);
    },
    promotionMerchantSaveBatch2(){
      console.log("promotionMerchantSaveBatch2");
      console.log(this.addSelection);
      console.log("promotionMerchantSaveBatch2");
      this.pomotionListObject.pomotionList.splice(0,this.pomotionListObject.pomotionList.length);
      console.log("pomotionList");
      console.log(this.pomotionListObject.pomotionList);
      console.log("pomotionList2");

      for (var i = 0; i < this.addSelection.length; i++) {
        var temp = {};

        temp.promotionId = this.promotionId;
        temp.merchantId =  this.addSelection[i].id;
        temp.merchantType = "1";
        temp.merchantName = this.addSelection[i].name;
        temp.merchantTypeManager=this.addSelection[i].merchantType;
        temp.orgNumber=this.addSelection[i].orgNumber;
        temp.name = this.addSelection[i].name;

        this.pomotionListObject.pomotionList.push(temp);
      }
      console.log("promotionMerchantSaveBatch2 push ok");
      console.log(this.pomotionListObject.pomotionList);
      console.log("promotionMerchantSaveBatch2 push ok2");

      let callback = res => {
        console.log(res);
        if (res.code == "0000") {
          this.mainMerchantForm.merchantType="1";
          this.mainMerchantFormFind();
        }
      };

      var  this__= this;
      this.utils.request.promotionMerchantSaveBatch2(this.pomotionListObject, callback );

      console.log("----ok");
      console.log(this.merchantTableData2);
      console.log("----ok2");

    },
    //查询商家
    merchantFormFind(){
      var  this__= this;
      this.utils.request.queryMerchantList(this.merchantForm, function (res) {
        // this.utils.request.queryMerchantListOther(null, function (res) {
        if (res.code == "0000") {
          this__.merchantTableData= res.data;
          this__.merchantTableDataTatol = res.totle;
        }
      });
    },
    //------setp2###end


  },
  mounted() {

    console.log(this.$route.query.id);
    console.log("-------------------------------查询开始");
    var param={};
    param.id = this.$route.query.id;

    this.promotionId = this.$route.query.id;
    this.promotion.promotionId = this.promotionId ;
    this.mainMerchantForm.promotionId = this.promotionId ;
    this.mainStoreMerchantForm.promotionId = this.promotionId ;

    this.mainMerchantFormFind();
    this.mainStoreTableDataFormFind();

    // var this_ = this;
    // this.$axios.post("jic-market/patch-groupon-theme/detail",qs.stringify(queryparam)).then(res => {
    //   console.log(res);
    //   if(res.data.code =="0000") {
    //     this_.activityData = res.data.data.rows;
    //   }
    // });

    let _this = this;
    let callback = res => {
      console.log(res);
      if (res.code == "0000") {
        _this.activityData = res.data;
      }else{
        alert("获取促销详情失败");
      }
    };
    let params = {"id": this.$route.query.value};
    this.utils.request.promotionDetailById(params, callback);


    // 参与商品详情
    let callback2 = res => {
      if (res.code == "0000") {
        this.tableDataData=res.data.rows;
      }
    };
    var param2 ={};
    param2.promotionId = this.$route.query.id;
    param2.start=1;
    param2.limit=10;
    this.utils.request.promotionMerchantProductList(param2, callback2);
    // 参与商品详情


    console.log("-------------------------------查询结束");
  }
};
</script>

<style scoped>
.border {
    color: #666666;
    font-size: 16px;
    font-weight: bold;
    line-height: 28px;
    border-bottom: 1px solid #666666;
    padding-bottom: 3px;
}
.pdL10 {
  padding-left: 10px!important;
}
.mgB15 {
    margin-bottom: 15px!important;
}
.border-left {
    border-left: 3px #ddd solid !important;
}
.font-bold {
    font-weight: 700;
}
.form-group {
    margin-bottom: 15px!important;
    margin-right: -0px!important;
    margin-left: -0px!important;
}
.form-horizontal .control-label {
    padding-top: 5px;
    margin-bottom: 0;
    text-align: right;
}
.form-horizontal div {
    font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif, "Regular", "Microsoft YaHei";
    font-size: 12px;
    color: #666666;
    background-color: transparent;
    -webkit-font-smoothing: antialiased;
    line-height: 1.42857143;
    word-wrap: break-word;
}
.form-horizontal .control-label {
    padding-top: 3px !important;
}
.col-sm-2 {
    width: 16.66666667%;
}
/* .col-sm-10 {
    width: 83.33333333%;
} */
.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 {
    float: left;
}
.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 {
    position: relative;
    min-height: 1px;
    padding-right: 15px;
    padding-left: 15px;
}
label {
    font-weight: normal;
}
label {
    display: inline-block;
    max-width: 100%;
    margin-bottom: 5px;
    font-weight: bold;
}
.form-group .pdt3px {
    padding-top: 3px;
}
.b-b {
    border-bottom: 1px solid #dddddd;
}
.line-dashed {
    border-style: dashed !important;
    background-color: transparent;
    border-width: 0;
}
.line-lg {
    margin-top: 15px;
    margin-bottom: 15px;
}
.line {
    width: 100%;
    height: 2px;
    margin: 10px 0;
    font-size: 0;
    overflow: hidden;
}
table {
    background-color: transparent;
}
table {
    border-spacing: 0;
    border-collapse: collapse;
}
.i-checks {
    padding-left: 0;
    margin-right: 15px;
    cursor: pointer;
    color: #666666;
}
.radio-inline, .checkbox-inline {
    display: inline-block;
    padding-left: 20px;
    margin-bottom: 0;
    font-weight: normal;
    vertical-align: middle;
    cursor: pointer;
}
.panel-body tr {
    padding: 0 15px;
}
</style>
